﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;  //引用Profile基类
using NationalD3.Application.ViewModels;
using NationalD3.Domain.Entities;

namespace NationalD3.Application.AutoMapper
{
    public class DomainToViewModelMappingProfile : Profile
    {
        public DomainToViewModelMappingProfile()
        {
            //复杂拷贝，需要进行手动配置一对一映射配置
            CreateMap<Student, StudentViewModel>()
                .ForMember(d=>d.Province, o=>o.MapFrom(s=>s.Address.Province))
                .ForMember(d => d.City, o => o.MapFrom(s => s.Address.City))
                .ForMember(d => d.County, o => o.MapFrom(s => s.Address.County))
                .ForMember(d => d.Street, o => o.MapFrom(s => s.Address.Street));
        }
    }
}
